***File used to compute results and generate tables for Murphy et al. "Chatting at Church: Information Diffusion through Religious Networks"



clear all
macro drop _all

*CUSTOM DO FILES
ssc install outreg2
ssc install plausexog
ssc install ivreg2
ssc install tuples
ssc install reghdfe

global user "[INSERT PATH HERE]"
cd "${user}"


use dyadic_data, clear

*Creating Sum/Difference Variables


global villagenum villagenum2 villagenum3 villagenum4 villagenum6 villagenum7 villagenum8 villagenum9 villagenum10 villagenum11 villagenum12 villagenum13 villagenum14 villagenum15 villagenum16 villagenum17 villagenum18
global enumerator enumerator2 enumerator3 enumerator4 enumerator5
global similarityvars comptwofullseas manutwofullseas crestwofullseas ureatwofullseas daptwofullseas npktwofullseas cantwofullseas pesttwofullseas orgtwofullseas inorgtwofullseas 
global similarityvarsmatch comptwofullseasmatch manutwofullseasmatch crestwofullseasmatch ureatwofullseasmatch daptwofullseasmatch npktwofullseasmatch cantwofullseasmatch pesttwofullseasmatch orgtwofullseasmatch inorgtwofullseasmatch 
global heardofvars grmanuheardof vermiheardof biocharheardof napierpullheardof desmodpushheardof compeverheard npkeverheard ureaeverheard
global heardofvarsmatch grmanuheardofmatch vermiheardofmatch biocharheardofmatch napierpullheardofmatch desmodpushheardofmatch compeverheardmatch npkeverheardmatch ureaeverheardmatch
global knowvars biochardescribebi vermidescribebi
global knowvarsmatch biochardescribebimatch vermidescribebimatch
global covariateslimited polyhh redo hhead age yrseduc hhsize math1 assetindx tlu widow totalcultareaacres bukusu luhyaother tribeother  
global covariateslimitedmatch polyhhmatch redomatch hheadmatch agematch yrseducmatch hhsizematch math1match assetindxmatch tlumatch widowmatch totalcultareaacresmatch bukusumatch luhyaothermatch tribeothermatch 
global covariatesquad age2 yrseduc2 totalcultareaacres2  
global covariatesquadmatch age2match yrseduc2match totalcultareaacres2match



global varsforsumdiff1 $covariateslimited
global varsforsumdiffmatch1 $covariateslimitedmatch
global varsforsumdiff2 $covariatesquad
global varsforsumdiffmatch2 $covariatesquadmatch
global monthdum monthdum2 monthdum3 monthdum4 monthdum5
local num1 : word count $varsforsumdiff1

global sumvars1
global diffvars1

forvalues x=1/`num1'{
local z : word `x' of $varsforsumdiff1
local y : word `x' of $varsforsumdiffmatch1
gen `z'sum=`z'+`y'
gen `z'diff=`z'-`y'
sum `z'diff, detail
global sumvars1 $sumvars1 `z'sum
global diffvars1 $diffvars1 `z'diff 
}

global sumvars2 $sumvars1
global diffvars2 $diffvars1
local num2 : word count $varsforsumdiff2

forvalues x=1/`num2'{
local z : word `x' of $varsforsumdiff2
local y : word `x' of $varsforsumdiffmatch2
gen `z'sum=`z'+`y'
gen `z'diff=`z'-`y'
sum `z'diff, detail
global sumvars2 $sumvars2 `z'sum
global diffvars2 $diffvars2 `z'diff 
}

global similarity
local num2 : word count $similarityvars
local num3 : word count $knowvars
local num4 : word count $heardofvars

forvalues x=1/`num2'{
local z: word `x' of $similarityvars
local y : word `x' of $similarityvarsmatch
gen both`z'=(`z'==`y')
global similarity $similarity both`z'
}
forvalues x=1/`num3'{
local z: word `x' of $knowvars
local y : word `x' of $knowvarsmatch
gen both`z'=(`z'==`y')
global know $know both`z'
}
egen avgknow=rowmean(bothbiochardescribebi bothvermidescribebi)
global know $know avgknow
global knowvars $knowvars avgknow

gen bothfielddayeverattend= fielddayeverattend==fielddayeverattendmatch
global know $know bothfielddayeverattend
global knowvars $knowvars fielddayeverattend

forvalues x=1/`num4'{
local z: word `x' of $heardofvars
local y : word `x' of $heardofvarsmatch
gen both`z'=(`z'==`y')
global heardof $heardof both`z'
}
egen avgheard=rowmean(bothgrmanuheardof bothvermiheardof bothbiocharheardof bothnapierpullheardof bothdesmodpushheardof bothcompeverheard bothnpkeverheard bothureaeverheard)
global heardof $heardof avgheard
global heardofvars $heardofvars avgheard

global regressorssums polyhhsum redosum hheadsum agesum age2sum yrseducsum yrseduc2sum hhsizesum math1sum assetindxsum tlusum widowsum totalcultareaacressum totalcultareaacres2sum bukususum luhyaothersum tribeothersum
global regressorsdiffs polyhhdiff redodiff hheaddiff agediff age2diff yrseducdiff yrseduc2diff hhsizediff math1diff assetindxdiff tludiff widowdiff totalcultareaacresdiff totalcultareaacres2diff bukusudiff luhyaotherdiff tribeotherdiff

label var indvidindvidmatch "Unique identfier for individuals in $ ij $ dyad"
label var hhidhhidmatch "Identifier for household dyad"
label var hhid "Household identifier of $ i $"
label var indvid "Individual identifier of $ i $"
label var netid "Network identifier of $ i $"
label var netidmatch "Network identifer of $ j $"
label var indvidmatch "Individual identifier of $ j $"
label var hhidmatch "Household identifier of $ j $"
label var villagenum "Village of dyad $ ij $"
label var netidmatchvill "Concatenation of network identfier of $ j $ and village number"
label var freqspoke "Frequency of speaking with $ j $: 1=daily 9=never"
label var county "County"
label var enumerator "Enumerator code of $ i $"
label var enumeratormatch "Enumerator code of $ j $"
label var know_indv "Know individual $ j $"
label var met_indv "Have met individual $ j $ in person"
label var trustvaluable_indv "Trust $ j $ to watch a valuable for you for one week"
label var infoquality_indv "Level of perceived info. quality from $ j $: 1=low 5=high"
label var infoqualitybi "High level of info. quality from $ j $ (4 or 5 on 5pt scale=1)"
label var infoqualitybi1 "High level of info. quality from $ j $ (5 on 5pt scale=1)"
label var friendshipbi "Close Friend ($ j $) (4 or 5 on 5pt scale=1)"
label var friendshipbi1 "Close Friend ($ j $) (5 on 5pt scale=1)"
label var religiousinst_indv "Religious institution co-membership ($ \zeta_{ij} $)"
label var trustvaluable_indv "Trust $ j $ to watch valuable item for one week"
label var friendship_indv "Stated level of friendship with $ j $: 1=low 5=high"
label var timeknown10yr "Known $ j \geq 10$ years"
label var family_indv "Immediate family of $ j $"
label var familyext_indv "Extended family of $ j $"
label var distk "Distance to $ j $ (kilometers)"
label var distk2 "Squared distance to $ j $ (kilometers)"
label var distk3 "Distance^3 to $ j $ (kilometers)"
label var distk4 "Distance^4 to $ j $ (kilometers)"
label var malemale "Male$ _i $ - Male$ _j $"
label var malefemale "Male$ _i $ - Female$ _j $"
label var femalefemale "Female$ _i $ - Female$ _j $"
label var femalemale "Female$ _i $ - Male$ _j $"
label var minmidchurchdist "Minimum $ ij $ RI distance (kilometers)"
label var percentsumchurchmatch5 "Nearest $ ij $ RI matches"
label var churchsmallbi "Small RI ($ RI_{sml} $)"
label var religiousinst_small "RI co-membership $ \times $ small RI ($ \zeta_{ij}\times RI_{sml} $)"
label var avgdistneighsum "Avg. distance neighbours ($ \tau_{ij} $)"
label var religiousinst_avgdistneigh "RI co-membership $ \times $ avg. dist. nbrs. ($ \zeta_{ij}\times \tau_{ij} $)"
label var freqspokebi1 "Speak at least weekly with $ j $"
label var freqspokedaily "Speak daily with $ j $"
label var freqspokeweekly "Speak weekly with $ j $"
label var samechurch "$ ij $ attend same church based on indv. responses"
label var nonrelorg_indv "Attend same non-religious organization as $ j $"
label var fertadvice_indv "Fertilizer advice received from $ j $ in last 12 months"
label var plantadvice_indv "Planting advice received from $ j $ in last 12 months"
label var buyeradvice_indv "Crop buyer advice received from $ j $ in last 12 months"
label var advice_indv "At least one form of advice received from $ j $ in last 12 months"
label var workedtogether_indv "Worked together with $ j $ in last 12 months"
label var polyhhsum "Polygamous household"
label var polyhhdiff "Polygamous household"
label var age2sum "Age squared"
label var age2diff "Age squared"
label var yrseduc2sum "Years of education squared"
label var yrseduc2diff "Years of education squared"
label var totalcultareaacres2sum "Total farm area squared (acres)"
label var totalcultareaacres2diff "Total farm area squared (acres)"
label var redosum "Repeated Survey$ \dagger $"
label var redodiff "Repeated Survey$ \dagger $"
label var hheadsum "Household head"
label var hheaddiff "Household head"
label var agesum "Age"
label var agediff "Age"
label var yrseducsum "Years of education"
label var yrseducdiff "Years of education"
label var hhsizesum "Household size"
label var hhsizediff "Household size"
label var math1sum "Math ability$ \ddagger $"
label var math1diff "Math ability$ \ddagger $"
label var assetindxsum "Asset index$ \dagger\dagger $"
label var assetindxdiff "Asset index$ \dagger\dagger $"
label var tlusum "TLU$ \ddagger\ddagger $"
label var tludiff "TLU$ \ddagger\ddagger $"
label var widowsum "Widow"
label var widowdiff "Widow"
label var totalcultareaacressum "Total farm area (acres)"
label var totalcultareaacresdiff "Total farm area (acres)"
label var bukususum "Bukusu subtribe"
label var bukusudiff "Bukusu subtribe"
label var luhyaothersum "Other Luhya tribe"
label var luhyaotherdiff "Other Luhya tribe"
label var tribeothersum "Other tribe"
label var tribeotherdiff "Other tribe"
label var sametribe "Same tribe"
label var jointprobiv2 "Joint $ ij $ probability RI attendance"
label var jointprobiv3 "Joint $ ij $ sq probability RI attendance"
label var timeknown_indv "Time known $ j $: 5=whole life"
label var freqspokemlogit "Transformed frequency speaking variable"
label var biochardescribebi "$ i $ can describe biochar"
label var vermidescribebi "$ i $ can describe vermicompost"
label var biochardescribebimatch "$ j $ can describe biochar"
label var vermidescribebimatch "$ j $ can describe vermicompost"
label var polyhh "$ i $ is in a polygamous household"
label var polyhhmatch "$ j $ is in a polygamous household"
label var redo "Results from a resurvey of $ i $"
label var redomatch "Results from a resurvey of $ j $"
label var hhead "Individual $ i $ is household head"
label var hheadmatch "Individual $ j $ is household head"
label var age "Age of $ i $ at time of survey"
label var agematch "Age of $ j $ at time of survey"
label var age2 "Age of $ i $ squared at time of survey"
label var age2match "Age of $ j $ squared at time of survey"
label var yrseduc "Years of education of $ i $ at time of survey"
label var yrseducmatch "Years of education of $ j $ at time of survey"
label var yrseduc2 "Years of education of $ i $ squared at time of survey"
label var yrseduc2match "Years of education of $ j $ squared at time of survey"
label var hhsize "Household size of $ i $"
label var hhsizematch "Household size of $ j $"
label var math1 "Can $ i $ do simple multiplication problem"
label var math1match "Can $ j $ do simple multiplication problem"
label var tlu "Tropical livestock units of $ i $"
label var tlumatch "Tropical livestock units of $ j $"
label var widow "Individual $ i $ is widow/er"
label var widowmatch "Individual $ j $ is widow/er"
label var bukusu "Individual $ i $ is a Bukusu"
label var bukusumatch "Individual $ j $ is a Bukusu"
label var luhyaother "Individual $ i $ is a non-Bukusu Luhya"
label var luhyaothermatch "Individual $ j $ is a non-Bukusu Luhya"
label var tribeother "Individual $ i $ is a non-Luhya and non-Teso"
label var tribeothermatch "Individual $ j $ is a non-Luhya and non-Teso"
label var maxchurchprob16 "Maximum church probability of $ i $"
label var maxchurchprobmatch16 "Maximum church probability of $ j $"
label var minchurchdist16 "Minimum church distance for $ i $"
label var minchurchdistmatch16 "Minimum church distance for $ j $"
label var plantcashcrop "Individual $ i $ planted a cash crop last season"
label var plantcashcropmatch "Individual $ j $ planted a cash crop last season"
label var attendanceavg "Average attendance of RI of $ i $"
label var attendanceavgmatch "Average attendance of RI of $ j $"
label var churchsmall "Individual $ i $ attends a small RI"
label var churchsmallmatch "Individual $ j $ attends a small RI"
label var percentsumchurchmatch5_small "Interacted variable"
label var percentsumchurchmatch5_avgdist "Interacted variable" 
label var minmidchurchdist_avgdistneigh "Interacted variable" 
label var minmidchurchdist_small "Interacted variable" 
label var closechurch_avgdistneigh "Interacted variable" 
label var jointprobiv3_avgdistneigh "Interacted variable" 
label var jointprobiv3_small "Interacted variable"
label var freqspokebi "Speak daily or most days with $ i $"
label var bothcomptwofullseas "Both $ i $ and $ j $ used compost last two seasons"
label var bothmanutwofullseas "Both $ i $ and $ j $ used manure last two seasons"
label var bothcrestwofullseas "Both $ i $ and $ j $ used crop residues last two seasons"
label var bothureatwofullseas "Both $ i $ and $ j $ used urea last two seasons"
label var bothdaptwofullseas "Both $ i $ and $ j $ used dap last two seasons"
label var bothnpktwofullseas "Both $ i $ and $ j $ used npk last two seasons"
label var bothcantwofullseas "Both $ i $ and $ j $ used can last two seasons"
label var bothpesttwofullseas "Both $ i $ and $ j $ used pesticide last two seasons"
label var bothorgtwofullseas "Both $ i $ and $ j $ used organic inputs last two seasons"
label var bothinorgtwofullseas "Both $ i $ and $ j $ used inorganic inputs last two seasons"
label var bothbiochardescribebi "Both $ i $ and $ j $ can describe biochar"
label var bothvermidescribebi "Both $ i $ and $ j $ can describe vermicompost"
label var avgknow "Average knowledge of agricultural techniques"
label var bothfielddayeverattend "Both $ i $ and $ j $ attended fieldday in 2016"
label var bothgrmanuheardof "Both $ i $ and $ j $ heard of green manure"
label var bothvermiheardof "Both $ i $ and $ j $ heard of vermicompost"
label var bothbiocharheardof "Both $ i $ and $ j $ heardof biochar"
label var bothnapierpullheardof "Both $ i $ and $ j $ heard of napier for pushpull"
label var bothdesmodpushheardof "Both $ i $ and $ j $ heard of desmodium for pushpull"
label var bothcompeverheard "Both $ i $ and $ j $ heard of compost"
label var bothnpkeverheard "Both $ i $ and $ j $ heard of npk"
label var bothureaeverheard "Both $ i $ and $ j $ heard of urea"
label var avgheard "Average ever heard of technique"

***Table 3***

global netsumstats know_indv met_indv friendshipbi1 infoqualitybi family_indv familyext_indv timeknown10yr freqspokebi1 freqspokedaily religiousinst_indv nonrelorg_indv fertadvice_indv plantadvice_indv buyeradvice_indv advice_indv workedtogether_indv trustvaluable_indv
mat mean_sd=J(17,2,.)
local i=1
foreach var in $netsumstats{
sum `var' if know_indv!=.
 mat mean_sd[`i',1] = r(mean)
 mat mean_sd[`i',2] = r(sd)
local i=`i'+1
} 
mat rownames mean_sd = know_indv met_indv friendshipbi1 infoqualitybi family_indv familyext_indv timeknown10yr freqspokebi1 freqspokedaily religiousinst_indv nonrelorg_indv fertadvice_indv plantadvice_indv buyeradvice_indv advice_indv workedtogether_indv trustvaluable_indv
frmttable, statmat(mean_sd) varlabels ctitles(Variable (n=8704 dyads), Mean, Std. Dev.)
mat samechurch=J(17,1,.)
local i=1
foreach var in $netsumstats{
sum `var' if know_indv!=.&samechurch==1
 mat samechurch[`i',1] = r(mean)
local i=`i'+1
} 
frmttable, statmat(samechurch) varlabels ctitle(Same Church) merge
mat diffchurch=J(17,1,.)
local i=1
foreach var in $netsumstats{
sum `var' if know_indv!=.&samechurch==0
 mat diffchurch[`i',1] = r(mean)
local i=`i'+1
} 
frmttable, statmat(diffchurch) varlabels ctitle(Different Church) merge

mat pvalue=J(17,1,.)
local i=1
foreach var in $netsumstats{
reg `var' samechurch if know_indv!=.
local t = _b[samechurch]/_se[samechurch]
local p =2*ttail(e(df_r),abs(`t'))
mat pvalue[`i',1]=`p'
local i=`i'+1
}
frmttable using "networksummarystats", statmat(pvalue) varlabels ctitle(P-value) tex frag merge replace



********************First stages************************

***Appendix table A5***

eststo f1: reghdfe  religiousinst_indv minmidchurchdist percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "No"
estadd local quadregressors "No"
estadd local clusters "883/883"
test minmidchurchdist percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo f2: reghdfe religiousinst_indv minmidchurchdist percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"
test minmidchurchdist percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo f3: reghdfe religiousinst_indv minmidchurchdist percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local clusters "883/883"
test minmidchurchdist percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo f4: reghdfe religiousinst_indv minmidchurchdist timeknown10yr family_indv familyext_indv distk distk2 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "No"
estadd local quadregressors "No"
estadd local clusters "883/883"
test minmidchurchdist
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)


eststo f5: reghdfe religiousinst_indv minmidchurchdist timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"
test minmidchurchdist
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)


eststo f6: reghdfe religiousinst_indv minmidchurchdist timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local clusters "883/883"
test minmidchurchdist
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)


eststo f7: reghdfe religiousinst_indv percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "No"
estadd local quadregressors "No"
estadd local clusters "883/883"
test percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo f8: reghdfe religiousinst_indv percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"
test percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo f9: reghdfe religiousinst_indv percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local clusters "883/883"
test percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)


esttab f1 f2 f3 f4 f5 f6 f7 f8 f9 using "firststageappendix.tex", label replace obslast se star(* 0.10 ** 0.05 *** 0.01) nomtitles mgroups("Attend Same RI as $ j $ $ (\zeta_{ij}) $", pattern(1 0 0 0 0 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) substitute(\_ _)  ///
scalars("clusters Number of clusters" "fixed Village/Enumerator/Svy. Month FE" "regressors HH/Demographic Vars." "quadregressors Quadratic Vars." "fstat F-test of instrument(s)" "pstat \quad prob$ >0 $")  b(2) sfmt(2) nonotes nogaps noomitted drop($sumvars2 $diffvars2)

***Appendix Table A6***

eststo f10: reghdfe  religiousinst_indv minmidchurchdist jointprobiv2 jointprobiv3 percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "No"
estadd local quadregressors "No"
estadd local clusters "883/883"
test minmidchurchdist jointprobiv2 jointprobiv3 percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo f11: reghdfe religiousinst_indv minmidchurchdist jointprobiv2 jointprobiv3 percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) //residuals(fsresiduals)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"
test minmidchurchdist jointprobiv2 jointprobiv3 percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo f12: reghdfe religiousinst_indv minmidchurchdist jointprobiv2 jointprobiv3 percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) //residuals(fsresiduals)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"
test minmidchurchdist jointprobiv2 jointprobiv3 percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo f13: reghdfe religiousinst_indv minmidchurchdist jointprobiv2 percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local clusters "883/883"
test minmidchurchdist jointprobiv2 percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo f14: reghdfe religiousinst_indv jointprobiv2 jointprobiv3 percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"
test jointprobiv2 jointprobiv3 percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo f15: reghdfe religiousinst_indv minmidchurchdist jointprobiv2 jointprobiv3 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"
test minmidchurchdist jointprobiv2 jointprobiv3
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo f16: reghdfe religiousinst_indv jointprobiv2 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"
test jointprobiv2 
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo f17: reghdfe religiousinst_indv jointprobiv2 jointprobiv3 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"
test jointprobiv2 jointprobiv3
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)
  
eststo f18: reghdfe religiousinst_indv jointprobiv2 jointprobiv3 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local clusters "883/883"
test jointprobiv2 jointprobiv3
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

esttab f10 f11 f12 f13 f14 f15 f16 f17 f18 using "firststageappendix2.tex", label replace obslast se star(* 0.10 ** 0.05 *** 0.01) nomtitles mgroups("Attend Same RI as $ j $ $ (\zeta_{ij}) $", pattern(1 0 0 0 0 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) substitute(\_ _)  ///
scalars("clusters Number of clusters" "fixed Village/Enumerator/Svy. Month FE" "regressors HH/Demographic Vars." "quadregressors Quadratic Vars." "fstat F-test of instrument(s)" "pstat \quad prob$ >0 $")  b(2) sfmt(2) nonotes nogaps noomitted drop($sumvars2 $diffvars2)



***********Reduced form**************


***Appendix table A7***


eststo r1: reghdfe  advice_indv minmidchurchdist percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "No"
estadd local quadregressors "No"
estadd local clusters "883/883"
test minmidchurchdist percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo r2: reghdfe advice_indv minmidchurchdist percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"
test minmidchurchdist percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo r3: reghdfe advice_indv minmidchurchdist percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local clusters "883/883"
test minmidchurchdist percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo r4: reghdfe advice_indv minmidchurchdist timeknown10yr family_indv familyext_indv distk distk2 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "No"
estadd local quadregressors "No"
estadd local clusters "883/883"
test minmidchurchdist
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)


eststo r5: reghdfe advice_indv minmidchurchdist timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"
test minmidchurchdist
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)


eststo r6: reghdfe advice_indv minmidchurchdist timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local clusters "883/883"
test minmidchurchdist
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)


eststo r7: reghdfe advice_indv percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "No"
estadd local quadregressors "No"
estadd local clusters "883/883"
test percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo r8: reghdfe advice_indv percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"
test percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo r9: reghdfe advice_indv percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local clusters "883/883"
test percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)


esttab r1 r2 r3 r4 r5 r6 r7 r8 r9 using "reducedformappendix.tex", label replace obslast se star(* 0.10 ** 0.05 *** 0.01) nomtitles mgroups("Attend Same RI as $ j $ $ (\zeta_{ij}) $", pattern(1 0 0 0 0 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) substitute(\_ _)  ///
scalars("clusters Number of clusters" "fixed Village/Enumerator/Svy. Month FE" "regressors HH/Demographic Vars." "quadregressors Quadratic Vars." "fstat F-test of instrument(s)" "pstat \quad prob$ >0 $")  b(2) sfmt(2) nonotes nogaps noomitted drop($sumvars2 $diffvars2)

***Appendix Table A8***

eststo r10: reghdfe  advice_indv minmidchurchdist jointprobiv2 jointprobiv3 percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "No"
estadd local quadregressors "No"
estadd local clusters "883/883"
test minmidchurchdist jointprobiv2 jointprobiv3 percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo r11: reghdfe advice_indv minmidchurchdist jointprobiv2 jointprobiv3 percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) //residuals(fsresiduals)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"
test minmidchurchdist jointprobiv2 jointprobiv3 percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo r12: reghdfe advice_indv minmidchurchdist jointprobiv2 jointprobiv3 percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) //residuals(fsresiduals)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"
test minmidchurchdist jointprobiv2 jointprobiv3 percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo r13: reghdfe advice_indv minmidchurchdist jointprobiv2 percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local clusters "883/883"
test minmidchurchdist jointprobiv2 percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo r14: reghdfe advice_indv jointprobiv2 jointprobiv3 percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"
test jointprobiv2 jointprobiv3 percentsumchurchmatch5
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo r15: reghdfe advice_indv minmidchurchdist jointprobiv2 jointprobiv3 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"
test minmidchurchdist jointprobiv2 jointprobiv3
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo r16: reghdfe advice_indv jointprobiv2 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"
test jointprobiv2 
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

eststo r17: reghdfe advice_indv jointprobiv2 jointprobiv3 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"
test jointprobiv2 jointprobiv3
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)
  
eststo r18: reghdfe advice_indv jointprobiv2 jointprobiv3 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local clusters "883/883"
test jointprobiv2 jointprobiv3
estadd scalar fstat=r(F)
estadd scalar pstat=r(p)

esttab r10 r11 r12 r13 r14 r15 r16 r17 r18 using "reducedformappendix2.tex", label replace obslast se star(* 0.10 ** 0.05 *** 0.01) nomtitles mgroups("Attend Same RI as $ j $ $ (\zeta_{ij}) $", pattern(1 0 0 0 0 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) substitute(\_ _)  ///
scalars("clusters Number of clusters" "fixed Village/Enumerator/Svy. Month FE" "regressors HH/Demographic Vars." "quadregressors Quadratic Vars." "fstat F-test of instrument(s)" "pstat \quad prob$ >0 $")  b(2) sfmt(2) nonotes nogaps noomitted drop($sumvars2 $diffvars2)

**************Primary Estimations***************************

***Table 4, Appendix table A11, Appendix table A12***

eststo a1: reghdfe advice_indv religiousinst_indv  timeknown10yr family_indv familyext_indv distk distk2 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "OLS"
estadd local fixed "Yes"
estadd local regressors "No"
estadd local quadregressors "No"
estadd local clusters "883/883"

eststo a2: reghdfe advice_indv religiousinst_indv malemale malefemale femalefemale timeknown10yr family_indv familyext_indv distk distk2 $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local type "OLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"


eststo a3: reghdfe advice_indv religiousinst_indv malemale malefemale femalefemale timeknown10yr family_indv familyext_indv distk distk2 $sumvars2 $diffvars2 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local type "OLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local clusters "883/883"


eststo a4: ivreghdfe advice_indv  timeknown10yr family_indv familyext_indv distk distk2 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "No"
estadd local quadregressors "No"
estadd local instr "2"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

eststo a5: ivreghdfe advice_indv malemale malefemale femalefemale timeknown10yr family_indv familyext_indv distk distk2 $sumvars1 $diffvars1 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) //resid (ssresiduals1)
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local instr "2"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

eststo a6: ivreghdfe advice_indv malemale malefemale femalefemale timeknown10yr family_indv familyext_indv distk distk2 $sumvars2 $diffvars2 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) //resid (ssresiduals1)
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local instr "2"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)


esttab a1 a2 a3 a4 a5 a6 using "primary.tex", label replace obslast se star(* 0.10 ** 0.05 *** 0.01) nomtitles mgroups("Received advice from $ j $", pattern(1 0 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) substitute(\_ _)  ///
scalars("type Estimation" "clusters Number of clusters" "fixed Village/Enumerator/Svy. Month FE" "regressors HH/Demographic Vars." "quadregressors Quadratic Vars." "instr Number of Instruments" "sidp Kleibergen-Paap rk LM P-values" "srkf Kleibergen-Paap rk Wald F-stat" "sjp Hansen J Statistics P-value")  b(2) sfmt(2) nonotes nogaps noomitted drop($sumvars2 $diffvars2)

esttab a1 a2 a3 a4 a5 a6 using "regressorssum.tex", label replace obslast se star(* 0.10 ** 0.05 *** 0.01) nomtitles mgroups("Received advice from $ j $", pattern(1 0 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) substitute(\_ _)  ///
scalars("type Estimation" "clusters Number of clusters" "fixed Village/Enumerator/Svy. Month FE" "regressors HH/Demographic Vars." "quadregressors Quadratic Vars." "instr Number of Instruments" "sidp Kleibergen-Paap rk LM P-values" "srkf Kleibergen-Paap rk Wald F-stat" "sjp Hansen J Statistics P-value")  b(2) sfmt(2) nonotes nogaps noomitted keep($sumvars2)

esttab a1 a2 a3 a4 a5 a6 using "regressorsdiff.tex", label replace obslast se star(* 0.10 ** 0.05 *** 0.01) nomtitles mgroups("Received advice from $ j $", pattern(1 0 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) substitute(\_ _)  ///
scalars("type Estimation" "clusters Number of clusters" "fixed Village/Enumerator/Svy. Month FE" "regressors HH/Demographic Vars." "quadregressors Quadratic Vars." "instr Number of Instruments" "sidp Kleibergen-Paap rk LM P-values" "srkf Kleibergen-Paap rk Wald F-stat" "sjp Hansen J Statistics P-value")  b(2) sfmt(2) nonotes nogaps noomitted keep($diffvars2)


***Appendix table A9***


eststo a7: ivreghdfe advice_indv  timeknown10yr family_indv familyext_indv distk distk2 (religiousinst_indv=minmidchurchdist jointprobiv2 jointprobiv3 percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "No"
estadd local quadregressors "No"
estadd local instr "4"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)


eststo a8: ivreghdfe advice_indv malemale malefemale femalefemale timeknown10yr family_indv familyext_indv distk distk2 $sumvars1 $diffvars1 (religiousinst_indv=minmidchurchdist jointprobiv2 jointprobiv3 percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)  //resid (ssresiduals2)
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local instr "4"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

eststo a9: ivreghdfe advice_indv malemale malefemale femalefemale timeknown10yr family_indv familyext_indv distk distk2 $sumvars2 $diffvars2 (religiousinst_indv=minmidchurchdist jointprobiv2 jointprobiv3 percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)  //resid (ssresiduals2)
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local instr "4"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)



esttab a7 a8 a9 using "primary2.tex", label replace obslast se star(* 0.10 ** 0.05 *** 0.01) nomtitles mgroups("Received advice from $ j $", pattern(1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) substitute(\_ _)  ///
scalars("type Estimation" "clusters Number of clusters" "fixed Village/Enumerator/Svy. Month FE" "regressors HH/Demographic Vars." "quadregressors Quadratic Vars." "instr Number of Instruments" "sidp Kleibergen-Paap rk LM P-values" "srkf Kleibergen-Paap rk Wald F-stat" "sjp Hansen J Statistics P-value")  b(2) sfmt(2) nonotes nogaps noomitted drop($sumvars2 $diffvars2)



*********Additional Results**************

***Appendix table A13***


eststo o1: ivreghdfe advice_indv churchsmallbi timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 (religiousinst_indv =minmidchurchdist percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local instr "2"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

eststo o2: ivreghdfe advice_indv churchsmallbi timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 (religiousinst_indv =minmidchurchdist percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local instr "2"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)


eststo o3: ivreghdfe advice_indv churchsmallbi timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 (religiousinst_indv religiousinst_small=minmidchurchdist percentsumchurchmatch5 percentsumchurchmatch5_small minmidchurchdist_small) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local instr "4"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

eststo o4: ivreghdfe advice_indv churchsmallbi timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 (religiousinst_indv religiousinst_small=minmidchurchdist percentsumchurchmatch5 percentsumchurchmatch5_small minmidchurchdist_small) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local instr "4"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

eststo o5: ivreghdfe advice_indv avgdistneighsum timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 (religiousinst_indv =minmidchurchdist percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local instr "2"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)


eststo o6: ivreghdfe advice_indv avgdistneighsum timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 (religiousinst_indv =minmidchurchdist percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local instr "2"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

eststo o7: ivreghdfe advice_indv avgdistneighsum timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 (religiousinst_indv religiousinst_avgdistneigh=minmidchurchdist percentsumchurchmatch5 percentsumchurchmatch5_avgdist minmidchurchdist_avgdistneigh) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local instr "4"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

eststo o8: ivreghdfe advice_indv avgdistneighsum timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 (religiousinst_indv religiousinst_avgdistneigh=minmidchurchdist percentsumchurchmatch5 percentsumchurchmatch5_avgdist minmidchurchdist_avgdistneigh) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local instr "4"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)



esttab o1 o2 o3 o4 o5 o6 o7 o8 using "alternativespecs.tex", label replace obslast se star(* 0.10 ** 0.05 *** 0.01) nomtitles mgroups("Received advice from $ j $", pattern(1 0 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) substitute(\_ _)  ///
scalars("type Estimation" "clusters Number of clusters" "fixed Village/Enumerator/Svy. Month FE" "regressors HH/Demographic Vars." "quadregressors Quadratic Vars." "instr Number of Instruments" "sidp Kleibergen-Paap rk LM P-values" "srkf Kleibergen-Paap rk Wald F-stat" "sjp Hansen J Statistics P-value") ///
 b(2) sfmt(2) nonotes nogaps noomitted drop(malemale malefemale femalefemale $sumvars2 $diffvars2) order(religiousinst_indv churchsmallbi religiousinst_small avgdistneighsum religiousinst_avgdistneigh)


***Table 5***


label var trustvaluable_indv "Trust"
label var infoqualitybi "Info Quality"
label var friendshipbi1 "Friendship"


eststo e1: reghdfe trustvaluable_indv religiousinst_indv timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local type "OLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"

eststo e2: ivreghdfe trustvaluable_indv timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local instr "2"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

eststo e3: ivreghdfe trustvaluable_indv timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local instr "2"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

eststo e4: reghdfe infoqualitybi religiousinst_indv timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local type "OLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"

eststo e5: ivreghdfe infoqualitybi timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local instr "2"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

eststo e6: ivreghdfe infoqualitybi timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local instr "2"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

eststo e7: reghdfe friendshipbi1 religiousinst_indv timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local type "OLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"

eststo e8: ivreghdfe friendshipbi1 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local instr "2"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

eststo e9: ivreghdfe friendshipbi1 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local instr "2"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)


esttab e1 e2 e3 e4 e5 e6 e7 e8 e9 using "mechanisms.tex", label replace obslast se star(* 0.10 ** 0.05 *** 0.01) nomtitles mgroups("Trust" "Info Quality" "Friendship", pattern(1 0 0 1 0 0 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) substitute(\_ _)  ///
scalars("type Estimation" "clusters Number of clusters" "fixed Village/Enumerator/Svy. Month FE" "regressors HH/Demographic Vars." "quadregressors Quadratic Vars." "instr Number of Instruments" "sidp Kleibergen-Paap rk LM P-values" "srkf Kleibergen-Paap rk Wald F-stat" "sjp Hansen J Statistics P-value")  b(2) sfmt(2) nonotes nogaps noomitted drop($sumvars2 $diffvars2)



***Appendix table A14***


label define freqspokem 0 "Never" 1 "Less than weekly" 2 "Weekly" 3 "More than weekly"
label values freqspokemlogit freqspokem

mlogit freqspokemlogit  religiousinst_indv timeknown10yr family_indv familyext_indv distk distk2  , b(2) cluster(indvid)
outreg2 using "mechanisms2", replace label nonotes dec(3) keep(religiousinst_indv malemale malefemale femalefemale timeknown10yr family_indv familyext_indv distk distk2) tex(frag) noni addtext(Number of clusters, 883, HH/Demographic Vars., Yes)


eststo e1: ologit friendship_indv timeknown10yr family_indv familyext_indv distk distk2  malemale malefemale femalefemale $villagenum $enumerator $monthdum $sumvars2 $diffvars2 , cluster(indvid)

esttab e1 using "friendship.tex",  label replace obslast se star(* 0.10 ** 0.05 *** 0.01) nomtitles refcat(polyhhsum "\rg{\textbf{Sums (X$ _i $+X$ _j $)}}" polyhhdiff "\rg{\textbf{Differences (X$ _i $-X$ _j $)}}", nolabel) substitute(\_ _) drop($villagenum $enumerator $monthdum) nonotes nogaps noomitted nomtitles
esttab e1 using "friendship.csv",  csv label replace obslast se star(* 0.10 ** 0.05 *** 0.01) nomtitles refcat(polyhhsum "\rg{\textbf{Sums (X$ _i $+X$ _j $)}}" polyhhdiff "\rg{\textbf{Differences (X$ _i $-X$ _j $)}}", nolabel) substitute(\_ _) drop($villagenum $enumerator $monthdum) nonotes nogaps noomitted nomtitles

predict friend_predict_ologit
reg friendship_indv malemale malefemale femalefemale timeknown10yr family_indv familyext_indv distk distk2 $villagenum $enumerator $monthdum $sumvars2 $diffvars2 , cluster(indvid)
predict friend_predict_ols
*/
sum friend_predict_ologit, detail

gen friend_predict_ologit1=(friend_predict_ologit>=r(p50))

***Appendix table A15***

eststo ss3: ivreghdfe advice_indv timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) if friend_predict_ologit1==0, absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local instr "2"
estadd local clusters "784/832"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp) 


eststo ss4: ivreghdfe advice_indv timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) if friend_predict_ologit1==1, absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local instr "2"
estadd local clusters "834/853"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp) 


esttab ss3 ss4 using "splitsample.tex", label replace obslast se star(* 0.10 ** 0.05 *** 0.01) nomtitles mgroups("Pr. Friend$ _{ij}< $ Median" "Pr. Friend$ _{ij}\geq $ Median", pattern(1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) substitute(\_ _)  ///
scalars("type Estimation" "clusters Number of clusters" "fixed Village/Enumerator/Svy. Month FE" "regressors HH/Demographic Vars." "quadregressors Quadratic Vars." "instr Number of Instruments" "sidp Kleibergen-Paap rk LM P-values" "srkf Kleibergen-Paap rk Wald F-stat" "sjp Hansen J Statistics P-value")  b(2) sfmt(2) nonotes nogaps noomitted drop($sumvars2 $diffvars2)

*****************Robustness******************

***Table A20***
eststo auto1: ivreghdfe advice_indv timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) if villagenum!=1&villagenum!=12, absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local instr "2"
estadd local villex "2"
estadd local clusters "792/792"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

eststo auto2: ivreghdfe advice_indv timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) if villagenum!=1&villagenum!=12, absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local instr "2"
estadd local villex "2"
estadd local clusters "792/792"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

eststo auto3: ivreghdfe advice_indv timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) if villagenum!=6&villagenum!=9&villagenum!=18, absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local instr "2"
estadd local villex "3"
estadd local clusters "727/727"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

eststo auto4: ivreghdfe advice_indv timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) if villagenum!=6&villagenum!=9&villagenum!=18, absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local instr "2"
estadd local villex "3"
estadd local clusters "727/727"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

esttab auto1 auto2 auto3 auto4 using "autocorrelation.tex", label replace obslast se star(* 0.10 ** 0.05 *** 0.01) nomtitles mgroups("Asset autocorr. excluded" "Religion autocorr. excluded", pattern(1 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) substitute(\_ _)  ///
scalars("type Estimation" "clusters Number of clusters" "fixed Village/Enumerator/Svy. Month FE" "villex Number of villages excluded" "regressors HH/Demographic Vars." "quadregressors Quadratic Vars." "instr Number of Instruments" "sidp Kleibergen-Paap rk LM P-values" "srkf Kleibergen-Paap rk Wald F-stat" "sjp Hansen J Statistics P-value")  b(2) sfmt(2) nonotes nogaps noomitted drop($sumvars2 $diffvars2)

***Young RIs ommitted***


eststo religion1: ivreghdfe advice_indv timeknown10yr family_indv familyext_indv distk distk2 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) if villagenum!=2&villagenum!=7, absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "No"
estadd local quadregressors "No"
estadd local instr "2"
estadd local villex "2"
estadd local clusters "793/793"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)


eststo religion2: ivreghdfe advice_indv timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) if villagenum!=2&villagenum!=7, absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local instr "2"
estadd local villex "2"
estadd local clusters "793/793"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

eststo religion3: ivreghdfe advice_indv timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) if villagenum!=2&villagenum!=7, absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local instr "2"
estadd local villex "2"
estadd local clusters "793/793"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

esttab religion1 religion2 religion3 using "nonewreligion.tex", label replace obslast se star(* 0.10 ** 0.05 *** 0.01) nomtitles   ///
scalars("type Estimation" "clusters Number of clusters" "fixed Village/Enumerator/Svy. Month FE" "villex Number of villages excluded" "regressors HH/Demographic Vars." "quadregressors Quadratic Vars." "instr Number of Instruments" "sidp Kleibergen-Paap rk LM P-values" "srkf Kleibergen-Paap rk Wald F-stat" "sjp Hansen J Statistics P-value")  b(2) sfmt(2) nonotes nogaps noomitted drop($sumvars2 $diffvars2)


***Appendix table A21***


eststo fam1: reghdfe family_indv religiousinst_indv timeknown10yr distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "OLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"

eststo fam2: ivreghdfe family_indv timeknown10yr distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local instr "2"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

eststo fam3: ivreghdfe family_indv timeknown10yr distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local instr "2"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

eststo fam4: reghdfe familyext_indv religiousinst_indv timeknown10yr distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local type "OLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local clusters "883/883"

eststo fam5: ivreghdfe familyext_indv timeknown10yr distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local instr "2"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

eststo fam6: ivreghdfe familyext_indv timeknown10yr distk distk2 malemale malefemale femalefemale $sumvars2 $diffvars2 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "Yes"
estadd local instr "2"
estadd local clusters "883/883"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)

esttab fam1 fam2 fam3 fam4 fam5 fam6 using "familyrel.tex", label replace obslast se star(* 0.10 ** 0.05 *** 0.01) nomtitles mgroups("Immediate family of $ j $" "Extended family of $ j $", pattern(1 0 0 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) substitute(\_ _)  ///
scalars("type Estimation" "clusters Number of clusters" "fixed Village/Enumerator/Svy. Month FE" "regressors HH/Demographic Vars." "quadregressors Quadratic Vars." "instr Number of Instruments" "sidp Kleibergen-Paap rk LM P-values" "srkf Kleibergen-Paap rk Wald F-stat")  b(2) sfmt(2) nonotes nogaps noomitted drop($sumvars2 $diffvars2)




***Appendix figure A5***
preserve
reg jointprobiv2 timeknown10yr family_indv familyext_indv malemale malefemale femalefemale $sumvars2 $diffvars2 $villagenum $enumerator $monthdum
predict prob
gen error=jointprobiv2-prob
drop if error>.7
twoway lpolyci religiousinst_indv jointprobiv2, legend(lab(2 "Kernel-weighted Polynomial Smoothing")) ytitle(RI co-membership) xtitle(Joint probability IV) bw(.1)
graph export "ErrorGraph.png", as(png) replace
restore


***Appendix table A16***


local num2 : word count $heardof

forvalues x=1/`num2'{
local y : word `x' of $heardof
local z : word `x' of $heardofvars
eststo sim1_`x': ivreghdfe `y' malemale malefemale femalefemale timeknown10yr family_indv familyext_indv distk distk2 $sumvars1 $diffvars1 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local instr "2"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)
sum `y' if religiousinst_indv!=.
estadd scalar mean=r(mean)
sum `z' if indvid==indvidmatch
estadd scalar orgmean=r(mean)
}
esttab sim1_1 sim1_2 sim1_3 sim1_4 sim1_5 sim1_6 sim1_7 sim1_8 sim1_9 using "agsimilarity11.tex", label replace obslast se star(* 0.10 ** 0.05 *** 0.01) nomtitles substitute(\_ _)  ///
mgroups("Gr. Manure" "Vermi" "Biochar" "Napier" "Desmodium" "Compost" "NPK" "Urea" "Aggregate Awareness", pattern(1 1 1 1 1 1 1 1 1 1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) scalars("type Estimation" "fixed Village/Enumerator/Svy. Month FE" "regressors HH/Demographic Vars." "quadregressors Quadratic Vars." "instr Number of Instruments" "sidp Kleibergen-Paap rk LM P-values" "srkf Kleibergen-Paap rk Wald F-stat" "sjp Hansen J Statistics P-value" "mean Dep. variable mean" "orgmean Mean for indv. $ i $")  b(2) sfmt(2) nonotes nogaps noomitted drop($sumvars1 $diffvars1)

***Appendix table A17***

local num3 : word count $know

forvalues x=1/`num3'{
local y : word `x' of $know
local z : word `x' of $knowvars
eststo sim2_`x': ivreghdfe `y' malemale malefemale femalefemale timeknown10yr family_indv familyext_indv distk distk2 $sumvars1 $diffvars1 (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch) 
estadd local type "2SLS"
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local quadregressors "No"
estadd local instr "2"
estadd scalar sidp=e(idp)
estadd scalar srkf=e(rkf)
estadd scalar sjp=e(jp)
sum `y' if religiousinst_indv!=.
estadd scalar mean=r(mean)
sum `z' if indvid==indvidmatch
estadd scalar orgmean=r(mean)
}
esttab sim2_1 sim2_2 sim2_3 sim2_4 using "agsimilarity21.tex", label replace obslast se star(* 0.10 ** 0.05 *** 0.01) nomtitles substitute(\_ _)  ///
mgroups("Biochar" "Vermicompost" "Average" "Attended Field Day", pattern(1 1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) scalars("type Estimation" "fixed Village/Enumerator/Svy. Month FE" "regressors HH/Demographic Vars." "quadregressors Quadratic Vars." "instr Number of Instruments" "sidp Kleibergen-Paap rk LM P-values" "srkf Kleibergen-Paap rk Wald F-stat" "sjp Hansen J Statistics P-value" "mean Dep. variable mean" "orgmean Mean for indv. $ i $")  b(2) sfmt(2) nonotes nogaps noomitted drop($sumvars1 $diffvars1)


***Appendix table A22***


*reduced form zero first stage group
reg advice_indv minmidchurchdist timeknown10yr family_indv familyext_indv distk distk2 $villagenum $enumerator $monthdum  if religiousinst_indv==0, cluster(indvid)

scalar mean1iv=_b[minmidchurchdist]
scalar rfz1iv=(_se[minmidchurchdist])^2

reg advice_indv minmidchurchdist timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 $villagenum $enumerator $monthdum  if religiousinst_indv==0, cluster(indvid)

scalar mean1iv_vars=_b[minmidchurchdist]
scalar rfz1iv_vars=(_se[minmidchurchdist])^2

reg advice_indv minmidchurchdist percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2  $villagenum $enumerator $monthdum if religiousinst_indv==0, cluster(indvid)

scalar mean2ivs1=_b[minmidchurchdist]
scalar mean2ivs2=_b[percentsumchurchmatch5]
scalar rfz2ivs1=(_se[minmidchurchdist])^2
scalar rfz2ivs2=(_se[percentsumchurchmatch5])^2

reg advice_indv minmidchurchdist percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 $villagenum $enumerator $monthdum if religiousinst_indv==0, cluster(indvid)

scalar mean2ivs_vars1=_b[minmidchurchdist]
scalar mean2ivs_vars2=_b[percentsumchurchmatch5]
scalar rfz2ivs_vars1=(_se[minmidchurchdist])^2
scalar rfz2ivs_vars2=(_se[percentsumchurchmatch5])^2

*reduced form rest of sample

reg advice_indv minmidchurchdist  timeknown10yr family_indv familyext_indv distk distk2 $villagenum $enumerator $monthdum if religiousinst_indv==1, cluster(indvid)

scalar rfone1iv=(_se[minmidchurchdist])^2

reg advice_indv minmidchurchdist  timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 $villagenum $enumerator $monthdum if religiousinst_indv==1, cluster(indvid)

scalar rfone1iv_vars=(_se[minmidchurchdist])^2

reg advice_indv minmidchurchdist percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 $villagenum $enumerator $monthdum if religiousinst_indv==1, cluster(indvid)
ereturn list

scalar rfone2ivs1=(_se[minmidchurchdist])^2
scalar rfone2ivs2=(_se[percentsumchurchmatch5])^2

reg advice_indv minmidchurchdist percentsumchurchmatch5 timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale $sumvars1 $diffvars1 $villagenum $enumerator $monthdum if religiousinst_indv==1, cluster(indvid)

scalar rfone2ivs_vars1=(_se[minmidchurchdist])^2
scalar rfone2ivs_vars2=(_se[percentsumchurchmatch5])^2


scalar se1iv=(.125*sqrt(rfz1iv+rfone1iv))^2
scalar se1iv_vars=(.125*sqrt(rfz1iv_vars+rfone1iv_vars))^2


scalar se2ivs1=(.125*sqrt(rfz2ivs1+rfone2ivs1))^2
scalar se2ivs2=(.125*sqrt(rfz2ivs2+rfone2ivs2))^2

scalar se2ivs_vars1=(.125*sqrt(rfz2ivs_vars1+rfone2ivs_vars1))^2
scalar se2ivs_vars2=(.125*sqrt(rfz2ivs_vars2+rfone2ivs_vars2))^2


eststo pe1: plausexog ltz advice_indv  timeknown10yr family_indv familyext_indv distk distk2  $villagenum $enumerator $monthdum (religiousinst_indv=minmidchurchdist ) , mu(`=mean1iv' ) omega(0 ) cluster(indvid)
estadd local fixed "Yes"
estadd local regressors "No"
estadd local instr "1"
estadd local uncertainty "No"

eststo pe2: plausexog ltz advice_indv  timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale  $sumvars1 $diffvars1 $villagenum $enumerator $monthdum (religiousinst_indv=minmidchurchdist ) , mu(`=mean1iv_vars' ) omega(0 ) cluster(indvid)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local instr "1"
estadd local uncertainty "No"

eststo pe3: plausexog ltz advice_indv  timeknown10yr family_indv familyext_indv distk distk2  $villagenum $enumerator $monthdum (religiousinst_indv=minmidchurchdist ) , mu(`=mean1iv' ) omega(`=se1iv' ) cluster(indvid)
estadd local fixed "Yes"
estadd local regressors "No"
estadd local instr "1"
estadd local uncertainty "Yes"

eststo pe4: plausexog ltz advice_indv  timeknown10yr family_indv familyext_indv distk distk2 malemale malefemale femalefemale  $sumvars1 $diffvars1  $villagenum $enumerator $monthdum (religiousinst_indv=minmidchurchdist ) , mu(`=mean1iv_vars' ) omega(`=se1iv_vars' ) cluster(indvid)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local instr "1"
estadd local uncertainty "Yes"

eststo pe5: plausexog ltz advice_indv  timeknown10yr family_indv familyext_indv distk distk2  $villagenum $enumerator $monthdum (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) , mu(`=mean2ivs1' `=mean2ivs2') omega(0 0) cluster(indvid)
estadd local fixed "Yes"
estadd local regressors "No"
estadd local instr "2"
estadd local uncertainty "No"

eststo pe6: plausexog ltz advice_indv  timeknown10yr family_indv familyext_indv distk distk2  malemale malefemale femalefemale $sumvars1 $diffvars1  $villagenum $enumerator $monthdum (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) , mu(`=mean2ivs1' `=mean2ivs2') omega(0 0) cluster(indvid)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local instr "2"
estadd local uncertainty "No"


eststo pe7: plausexog ltz advice_indv  timeknown10yr family_indv familyext_indv distk distk2  $villagenum $enumerator $monthdum (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) , mu(`=mean2ivs1' `=mean2ivs2') omega(`=se2ivs_vars1' `=se2ivs_vars2') cluster(indvid)
estadd local fixed "Yes"
estadd local regressors "No"
estadd local instr "2"
estadd local uncertainty "Yes"

eststo pe8: plausexog ltz advice_indv  timeknown10yr family_indv familyext_indv distk distk2  malemale malefemale femalefemale $sumvars1 $diffvars1  $villagenum $enumerator $monthdum (religiousinst_indv=minmidchurchdist percentsumchurchmatch5) , mu(`=mean2ivs1' `=mean2ivs2') omega(`=se2ivs_vars1' `=se2ivs_vars2') cluster(indvid)
estadd local fixed "Yes"
estadd local regressors "Yes"
estadd local instr "2"
estadd local uncertainty "Yes"


esttab pe1 pe2 pe3 pe4 pe5 pe6 pe7 pe8 using "plausexog.tex", label replace obslast se star(* 0.10 ** 0.05 *** 0.01) nomtitles substitute(\_ _)  ///
mgroups("Received advice from $ j $", pattern(1 0 0 0 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) scalars("uncertainty Estimation with uncertainty" "instr Number of Instruments" "fixed Village/Enumerator/Svy. Month FE" "regressors HH/Demographic Vars.")  b(2) sfmt(2) nonotes noobs nogaps noomitted drop($villagenum $enumerator $monthdum $sumvars1 $diffvars1)


***Appendix table A18*** NOTE: takes significant time to run this portion of code
forvalues x=6(3)9{
preserve
matrix A=J(1000,6,.)
matrix colnames A=F1 T1_MD T1_PCT F2 T2_MD T2_PCT
gen fstat1=.
gen fstat2=.
gen tstat1_1=.
gen tstat1_2=.
gen tstat2_1=.
gen tstat2_2=.
forvalues y=1/1000{
quietly reghdfe  religiousinst_indv minmidfakechurchdist`y'_`x' percentsumchurchmatch5fake`y'_`x'  malemale malefemale femalefemale timeknown10yr family_indv familyext_indv distk distk2 $sumvars1 $diffvars1, absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
replace tstat1_1=_b[minmidfakechurchdist`y'_`x']/_se[minmidfakechurchdist`y'_`x']
replace tstat1_2=_b[percentsumchurchmatch5fake`y'_`x']/_se[percentsumchurchmatch5fake`y'_`x']
quietly test minmidfakechurchdist`y'_`x' percentsumchurchmatch5fake`y'_`x'
replace fstat1=`r(F)'

matrix A[`y',1]=fstat1[1]
matrix A[`y',2]=tstat1_1[1]
matrix A[`y',3]=tstat1_2[1]


quietly reghdfe  religiousinst_indv minmidfakechurchdist`y'_`x' percentsumchurchmatch5fake`y'_`x' malemale malefemale femalefemale timeknown10yr family_indv familyext_indv distk distk2 $sumvars1 $diffvars1 , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
replace tstat2_1=_b[minmidfakechurchdist`y'_`x']/_se[minmidfakechurchdist`y'_`x']
replace tstat2_2=_b[percentsumchurchmatch5fake`y'_`x']/_se[percentsumchurchmatch5fake`y'_`x']
quietly test minmidfakechurchdist`y'_`x' percentsumchurchmatch5fake`y'_`x'
replace fstat2=`r(F)'

matrix A[`y',4]=fstat2[1]
matrix A[`y',5]=tstat2_1[1]
matrix A[`y',6]=tstat2_2[1]

}

svmat A
keep A1-A6

rename A1 F1
rename A2 T1_MD
rename A3 T1_PCT
rename A4 F2
rename A5 T2_MD
rename A6 T2_PCT

save FakeFirstStage`x'thSD, replace
restore

preserve
matrix A=J(1000,8,.)
matrix colnames A=underid1 hansen1 tstat_relinst1 pvalue1 underid2 hansen2 tstat_relinst2 pvalue2
gen underid1=.
gen underid2=.
gen hansen1=.
gen hansen2=.
gen tstat_relinst1=.
gen tstat_relinst2=.
gen pvalue1=.
gen pvalue2=.

forvalues y=1/1000{
quietly ivreghdfe advice_indv  malemale malefemale femalefemale  timeknown10yr family_indv familyext_indv distk distk2 $sumvars1 $diffvars1  (religiousinst_indv=minmidfakechurchdist`y'_`x' percentsumchurchmatch5fake`y'_`x') , absorb($villagenum $enumerator $monthdum) cluster(indvid indvidmatch)
replace underid1=`e(idp)'
replace hansen1=`e(jp)'
replace tstat_relinst1=_b[religiousinst_indv]/_se[religiousinst_indv]
replace pvalue1=ttail(e(df_r),abs(_b[religiousinst_indv]/_se[religiousinst_indv]))*2

matrix A[`y',1]=underid1[1]
matrix A[`y',2]=hansen1[1]
matrix A[`y',3]=tstat_relinst1[1]
matrix A[`y',4]=pvalue1[1]

}


svmat A
keep A1-A4
rename A1 underid1
rename A2 hansen1
rename A3 tstat_relinst1
rename A4 pvalue1


save FakeSecondStage`x'thSD, replace
restore
}

forvalues x=6(3)9{
use FakeSecondStage`x'thSD, clear
gen id=_n
order id
foreach var of varlist underid1-pvalue1{
rename `var' `var'_`x'
}
save FakeSecondStage`x'thSD1, replace
use FakeFirstStage`x'thSD, clear
gen id=_n
order id
foreach var of varlist F1-T2_PCT{
rename `var' `var'_`x'
}
save FakeFirstStage`x'thSD1, replace
}
clear all
use FakeFirstStage6thSD1, clear
merge 1:1 id using FakeFirstStage9thSD1, nogen
merge 1:1 id using FakeSecondStage6thSD1, nogen
merge 1:1 id using FakeSecondStage9thSD1, nogen
drop if id>1000

save fakeresults, replace

gen pvalue1_6_10=(pvalue1_6>.1)
gen pvalue1_6_05=(pvalue1_6>.05)
gen pvalue1_6_01=(pvalue1_6>.01)
gen pvalue1_9_10=(pvalue1_9>.1)
gen pvalue1_9_05=(pvalue1_9>.05)
gen pvalue1_9_01=(pvalue1_9>.01)


eststo: estpost summarize pvalue1_6 , detail
matrix statmat = e(mean)\ e(sd)
mat original=(0.030)
mat statmat=original \ statmat
matrix colnames statmat = pvalue1_6
mat statmat1=statmat'

eststo: estpost summarize pvalue1_6_10 pvalue1_6_05 pvalue1_6_01 , detail
matrix statmat2 = e(mean)


mat pvalues=statmat2
mat pvalues1=statmat1, pvalues

label var pvalue1_6 "P-value (2 IVs)"
label var F1_6 "F-stat (2 IVs)"
label var pvalue1_9 "P-value (2 IVs)"
label var F1_9 "F-stat (2 IVs)"

frmttable using IV_robustness2, tex statmat(pvalues1) replace frag sdec(2) ctitle("\rg{\textbf{1/6 SD Village-level RI}}", "", "", "", "\underline{\quad Percent of iterations \quad}" \ " ", "Original"  ,"Sim. Mean", "Std. Dev." , "$>0.10$",  "$>0.05$",   "$>0.01$") multicol(1,5,3) varlabels  hlines(1{0};1{0}1)


eststo: estpost summarize F1_6  , detail
matrix statmat = e(mean)\ e(sd) \ e(p5) \ e(p50) \ e(p95)
mat original=(15.73 )
mat statmat=original \ statmat
matrix colnames statmat = F1_6
mat statmat1=statmat'

frmttable using IV_robustness2, tex statmat(statmat1) addtable frag sdec(2) ctitle("\hspace{11em}", "" , "", "" , "\underline{\qquad \quad Percentile \quad \qquad}" \ " ", "Original" "Sim. Mean", "Std. Dev." , " \quad 5th \quad" , " \quad 50th \quad" , "  \quad 95th \quad") multicol(1,5,3) varlabels hlines(0{0};1{0}1)


eststo: estpost summarize pvalue1_9, detail
matrix statmat = e(mean)\ e(sd)
mat original=(0.030)
mat statmat=original \ statmat
matrix colnames statmat = pvalue1_9 
mat statmat1=statmat'

eststo: estpost summarize pvalue1_9_10 pvalue1_9_05 pvalue1_9_01, detail
matrix statmat4 = e(mean)


mat pvalues=statmat4 
mat pvalues1=statmat1, pvalues

frmttable using IV_robustness2, tex statmat(pvalues1) addtable frag sdec(2) ctitle("\rg{\textbf{1/9 SD Village-level RI}}", "" , "" , " " , "\underline{\quad Percent of iterations \quad}" \ " ", "Original" "Sim. Mean", "Std. Dev." ,"$>0.10$",  "$>0.05$",   "$>0.01$") multicol(1,5,3) varlabels hlines(0{0};1{0}1)


eststo: estpost summarize F1_9 , detail
matrix statmat = e(mean)\ e(sd) \ e(p5) \ e(p50) \ e(p95)
mat original=(15.73)
mat statmat=original \ statmat
matrix colnames statmat = F1_9
mat statmat1=statmat'

frmttable using IV_robustness2, tex statmat(statmat1) addtable frag sdec(2) ctitle("\hspace{11em}", "" , "", "" , "\underline{\qquad \quad Percentile \quad \qquad}" \ " ", "Original" "Sim. Mean", "Std. Dev." , " \quad 5th \quad" , " \quad 50th \quad" , "  \quad 95th \quad") multicol(1,5,3) varlabels hlines(0{0};1{0}1)






